<template>
  <basic-container>
    <div class="card-border">
      <card-header :header-data="headerData"></card-header>
      <avue-crud :data="scheduleData"
                 :option="option"
                 :page="page"
                 :table-loading="tableLoading"
                 @size-change="sizeChange"
                 @current-change="currentChange"
                 @search-change="searchChange"
                 @search-reset="searchReset"
                 class="avuecrud">
        <!--<template slot-scope="scope" slot="menu">-->
          <!--<div class="menu-title" @click.stop="reviewFinishedDetail(scope.row,scope.index)">-->
            <!--<i class="iconfont iconview icon-primary"></i>-->
            <!--<p class="menu-title-text">详情</p>-->
          <!--</div>-->
        <!--</template>-->
      </avue-crud>
    </div>
  </basic-container>
</template>
<script>
  import {reviewFinished} from "@/api/review";
  import {REVIEW_DIC, PROJECT_DIC} from "@/const/dict";

  export default {
    name: "toDoReviewFinished",
    data() {
      return {
        headerData: {
          title: '已办审批'
        },
        actPicUrl: '',
        showPicDialog: false,
        page: {
          total: 0, // 总页数
          currentPage: 1, // 当前页数
          pageSize: 10 // 每页显示多少条
        },
        tableLoading: false,
        scheduleData: [],
        option: {
          page: true,
          addBtn: false,
          editBtn: false,
          addRowBtn: false,
          indexLabel: "序号",
          index: true,
          indexWidth:70,
          cellBtn: false,
          delBtn: false,
          columnBtn: false,
          menu:false,
          refreshBtn: false,
          filterBtn: false,
          searchBtn: false,
          menuWidth: 100,
          keyId: "id",
          column: [
            {
              label: "规划名称",
              prop: "achievementTitle",
              cell: true,
              formatter: function (row, value, label, column) {
                return '<a style="cursor: pointer;" onclick="reviewFinishedDetail(\'' + row.achievementId + '\')">' + value + '</a>';
              }
            },{
              label: "规划名称",
              prop: "titleLike",
              search: true,
              hide: true,
              cell: true,
            },{
              label: "规划类型",
              prop: "category",
              width: '120',
              dicData: PROJECT_DIC.CATEGORY,
              cell: true,
            },
            {
              label: "规划等级",
              prop: "planningRank",
              type: "select",
              width: '120',
              dicData: PROJECT_DIC.PLANNING_RANK,
              cell: true,
            },
            {
              label: "拟发布范围",
              prop: "openScope",
              type: "select",
              width: '120',
              dicData: REVIEW_DIC.publishDIC,
              cell: true
            },
            {
              label: "状态",
              prop: "state",
              width: '120',
              dicData: REVIEW_DIC.stateDIC,
              cell: true
            },
          ]
        },
        titleLikeSearch:''
      };
    },
    created() {
      this.getToDoList(this.page)
      window.reviewFinishedDetail = this.reviewFinishedDetail;
    },
    methods: {
      // 详情
//      reviewFinishedDetail(row, index) {
//        let src = `/reviewFinishedDetail/detail`;
//        this.$router.push({
//          path: src,
//          query:{
//            achievementId:row.achievementId,
//          }
//        })
//      },

      reviewFinishedDetail(achievementId) {
        let src = `/reviewFinishedDetail/detail`;
        this.$router.push({
          path: src,
          query:{
            achievementId:achievementId,
          }

        });
      },

      getToDoList(page, params) {
        this.tableLoading = true;
        reviewFinished(Object.assign({
          current: page.currentPage,
          size: page.pageSize,
        }, params)).then(response => {
          this.scheduleData = response.data.data.records;
          this.page.total = response.data.data.total;
          this.tableLoading = false;
        })
      },

      /**
       * 刷新回调
       */
      searchReset () {
        this.titleLikeSearch = '';
        let params = {
          titleLike:this.titleLikeSearch,
        };
        this.getToDoList(this.page,params);
      },
      //搜索回调
      searchChange (params) {
        this.page.currentPage = 1
        this.getToDoList(this.page, this.dealSearchParam(params));
      },
      // 处理搜索过滤
      dealSearchParam (params) {
        if (params.titleLike) {
          params.titleLike = params.titleLike;
        }
        this.titleLikeSearch = params.titleLike;
        return params;
      },
      currentChange(currentPage) {
        var page = this.page;
        page.currentPage = currentPage;
        let params = {
          titleLike:this.titleLikeSearch,
        };
        this.getToDoList(page,params);
      },
      sizeChange(pageSize) {
        var page = this.page;
        page.pageSize = pageSize;
        let params = {
          titleLike:this.titleLikeSearch,
        };
        this.getToDoList(page,params);
      },

      handleSubmit() {

      },

    }
  };
</script>

<style lang="scss" scoped>

</style>
